using UnityEngine;

namespace CinemaDirector
{
	public abstract class GGTweenPropertyBase<T> : CinemaGlobalAction
	{
		public GameObject obj;

		public T duringValue;

		public T afterValue;

		protected T cachedProperty;

		public abstract void SetProperty(T newPropertyValue);

		public abstract T GetProperty();

		public override void Trigger()
		{
			SetProperty(duringValue);
		}

		public override void Initialize()
		{
			cachedProperty = GetProperty();
		}

		public override void Stop()
		{
			if (!Application.isPlaying)
			{
				SetProperty(cachedProperty);
			}
		}

		public override void ReverseTrigger()
		{
			End();
		}

		public override void End()
		{
			SetProperty(afterValue);
		}

		public override void ReverseEnd()
		{
			Trigger();
		}

		public override void UpdateTime(float time, float deltaTime)
		{
			if (time >= 0f && time <= base.Duration)
			{
				SetProperty(duringValue);
			}
			else
			{
				SetProperty(afterValue);
			}
		}

		public override void SetTime(float time, float deltaTime)
		{
			if (!(time < 0f) && !(time > base.Duration))
			{
				UpdateTime(time, deltaTime);
			}
		}
	}
}
